$(document).ready(function() {
	
	getserInfoBySession();
});

/**
 * 获取用户信息并初始赋值
 */
function getserInfoBySession(){
	var getserinfobysessionURL = getContextPath()+"/user/getserinfobysession";
	$.get(getserinfobysessionURL, function(data) {
		console.log(data);
		var obj=eval("("+data+")"); //转换json
		if(obj.sucess == true){
		var user = obj.user;
		$('#userImage').attr('src',"/file/image/"+user.userImageUrl);
		$('input[name="userPhone"]').val(user.userPhone);
		$('input[name="userEmail"]').val(user.userEmail);
		$('input[name="userAddress"]').val(user.userAddress);
		}else{
			alert('获取用户信息失败')
		}
	});
}



function getContextPath() { //获取根路径

	var pathName = document.location.pathname;
	var index = pathName.substr(1).indexOf("/");
	var result = pathName.substr(0, index + 1);
	return result;
}